home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 September / Australian PC User - September 2003 (CD1).iso / magstuff / web / files / dwmx61.exe / Disk1 / data1.cab / Configuration_En / Commands / Keyboard Shortcuts.js < prev    next >
Encoding:
JavaScript  |  2002-11-25  |  35.1 KB  |  1,134 lines

  1. // Copyright 2000-2002 Macromedia, Inc. All rights reserved.
  2.  
  3. // *** add case where no sets defined
  4. var DEBUG_FILE = dw.getConfigurationPath() + '/SHORTCUT_DEBUG.txt';
  5.  
  6. //*************** GLOBALS *****************
  7. var helpDoc = MM.HELP_cmdKeyboardShortcuts;
  8. var ultraDevMenuStr = "ultradev";
  9. var PLATFORM = navigator.platform;
  10. var OPP_PLATFORM = (PLATFORM == "Win32") ? "mac" : "win";  // Opposite platform
  11. var CTRL_STR = (PLATFORM == "Win32") ? "Ctrl" : "Cmd";
  12. var NEWLINE = (PLATFORM != "Win32") ? "\x0D" : "\x0D\x0A";
  13. var FILE_CONFIG_PATH = dw.getConfigurationPath();
  14. var FILE_MENUXML_PATH   = null;
  15. var FILE_CUSTOM_SET = FILE_CONFIG_PATH + "/Menus/Custom Sets";
  16. var FILE_ACTIVE_SET = FILE_CUSTOM_SET + "/active set.txt";
  17. var ARRAY_COMMANDS_TREE = new Array();
  18. var ARRAY_COMMANDS_TREENODES = new Array();
  19. var ARRAY_CUSTOM_SETS;
  20. var ACTIVE_SHORTCUT_LIST = new ShortcutList();   // ShortcutList() class defined in Shortcut.js
  21. var CURRENT_SHORTCUT_LIST = new ShortcutList();
  22. var MENU_DOM = null;
  23. var TREE_CONTROL_WIDTH = 'style="width:345px"';
  24. var TREE_COLUMN_ITEM_WIDTH = 'width="158"';
  25. var TREE_COLUMN_ITEM_WIDTH_MAC = 'width="220"'
  26. var TREE_COLUMN_KEY_WIDTH = 'width="90"';
  27. var SEPARATOR_STR = "-----------------------------------------------";
  28. var ACTIVE_SET_STR;
  29. var YIELD_PATH = "../Shared/MM/Images/yield.gif";
  30. var STOP_PATH = "../Shared/MM/Images/stop.gif";
  31. var ALT_STR = (PLATFORM == "Win32") ? "Alt" : "Opt";
  32. var CONFLICT_ID="";
  33. var CAN_APPLY=true;
  34. var LEFT_LAYER = 'left:235px;';
  35. var RIGHT_LAYER = 'left:321px;';
  36. var TOP_LAYER = 'top:402px;';
  37. var LAST_VALID_COMMAND_MI = "";  //last valid command menu item
  38. var MODIFIER_KEYS = new Array("Ctrl","Cmd","Alt","Opt","Shift");
  39. // UI Globals
  40. var IBTN_duplicateBtn, IBTN_renameBtn, IBTN_saveAsTextBtn, IBTN_deleteBtn,IBTN_addBtn;
  41. //******************* API **********************
  42.  
  43. function loadGlobals()
  44.   {
  45.   if (FILE_MENUXML_PATH != null &&
  46.     MENU_DOM != null)
  47.     return;
  48.  
  49.   FILE_MENUXML_PATH = dw.getMenuFile();
  50.   MENU_DOM = dw.getDocumentDOM(FILE_MENUXML_PATH);
  51.   }
  52.  
  53. function cmdOK()
  54. {
  55.   checkLockedFiles();
  56.   if (document.newShortcutEntry.value && !isSet(MENU_CURRENT_SET.getValue(), "factory"))
  57.     updateUI("applyButton");
  58.   var activeSet = CURRENT_SHORTCUT_LIST.shortcutListName;
  59.   if (!isSet(MENU_CURRENT_SET.getValue(), "factory"))
  60.     CURRENT_SHORTCUT_LIST.writeToShortcutXML(FILE_CUSTOM_SET+"/"+ MENU_CURRENT_SET.getValue(), CURRENT_SHORTCUT_LIST.shortcutListName);
  61.   window.close();
  62.   dreamweaver.runCommand("Processing.htm",CURRENT_SHORTCUT_LIST,FILE_ACTIVE_SET,activeSet,document);
  63. }
  64.  
  65. function editMenuXML(shortcutList,activeSetPath,activeSet)
  66. {
  67.   writeToMenusXML(shortcutList);
  68.   DWfile.write(activeSetPath, activeSet);
  69.   dreamweaver.reloadMenus();
  70. }
  71.  
  72. function cmdCancel()
  73. {
  74.   window.close();
  75. }
  76.  
  77. function cmdSaveAsText()
  78. {
  79.   var browseURL;
  80.   browseURL = dreamweaver.browseForFileURL("save",LABEL_SaveAsHTML);
  81.   if (browseURL)
  82.   {
  83.   if(browseURL.lastIndexOf(".htm")== -1)
  84.     browseURL +=".htm";
  85.   DWfile.write(browseURL, createHTMLContents());
  86.   }
  87. }
  88.  
  89. //***************** LOCAL FUNCTIONS  ******************
  90.  
  91. function initializeUI()
  92. {
  93.   var  i, commandsArray, menuLabel;
  94.  
  95.   if(checkLockedFiles())
  96.   {
  97.     window.close();
  98.     return;
  99.   }
  100.  
  101.   // Global UI Controls
  102.   MENU_CURRENT_SET = new ListControl("selectCurrentSet");
  103.   MENU_COMMANDS = new ListControl("commandsList");
  104.   LIST_SHORTCUTS = new ListControl("itemList");
  105.   IBTN_duplicateBtn = new ImageButton("duplicateBtn","IBTN_duplicateBtn","sS",false);
  106.   IBTN_renameBtn = new ImageButton("renameBtn","IBTN_renameBtn","sS",false);
  107.   IBTN_saveAsTextBtn = new ImageButton("saveAsTextBtn","IBTN_saveAsTextBtn","sS",false);
  108.   IBTN_deleteBtn = new ImageButton("deleteBtn","IBTN_deleteBtn","sS",false);
  109.   IBTN_addBtn = new ImageButton("addBtn","IBTN_addBtn","sS",false);
  110.   IBTN_minusBtn = new ImageButton("minusBtn","IBTN_minusBtn","sS",false);
  111.   //
  112.   setCurrentSetMenu();
  113.   // select the active set
  114.   MENU_CURRENT_SET.setIndex(getIndexOfItem(MENU_CURRENT_SET.get('all'),ACTIVE_SET_STR));
  115.   LAST_VALID_COMMAND_MI = MENU_CURRENT_SET.getValue();
  116.   if (PLATFORM == "Win32"){
  117.     if (dw.isMDI()){
  118.       commandsArray = new Array(LABEL_MainMenu, LABEL_SitePanel, SEPARATOR_STR, LABEL_HTMLWindow, LABEL_MainWindow, LABEL_SiteWindow );
  119.     }else{
  120.       commandsArray = new Array(LABEL_MainMenu, LABEL_SiteMenu, SEPARATOR_STR, LABEL_HTMLWindow, LABEL_MainWindow, LABEL_SiteWindow );
  121.     }
  122.   }else{
  123.     commandsArray = new Array(LABEL_MainMenu,SEPARATOR_STR, LABEL_HTMLWindow, LABEL_MainWindow);
  124.   }
  125.   MENU_COMMANDS.setAll(commandsArray,commandsArray);
  126.   MENU_COMMANDS.setIndex(0);
  127.  
  128.   // create treenode array
  129.   for (i=0; i < MENU_COMMANDS.getLen(); i++)
  130.   {
  131.     menuLabel = MENU_COMMANDS.get(i);
  132.     if (menuLabel == LABEL_MainMenu)
  133.     ARRAY_COMMANDS_TREENODES.push(readFromMenuXML("menubar","DWMainWindow"));
  134.   else if (menuLabel == LABEL_SiteMenu)
  135.     ARRAY_COMMANDS_TREENODES.push(readFromMenuXML("menubar","DWMainSite"));
  136.   else if (menuLabel == LABEL_SitePanel)
  137.     ARRAY_COMMANDS_TREENODES.push(readFromMenuXML("menubar","DWSiteMenuPopup"));
  138.   else if (menuLabel == LABEL_HTMLWindow)
  139.     ARRAY_COMMANDS_TREENODES.push(readFromMenuXML("shortcutlist","DWHTMLContext"));
  140.   else if (menuLabel == LABEL_MainWindow)
  141.     ARRAY_COMMANDS_TREENODES.push(readFromMenuXML("shortcutlist","DWMainWindow"));
  142.   else if (menuLabel == LABEL_SiteWindow)
  143.     ARRAY_COMMANDS_TREENODES.push(readFromMenuXML("shortcutlist","DWMainSite"));
  144.   else
  145.     ARRAY_COMMANDS_TREENODES.push( "-");
  146.   }
  147.  
  148.   generateTreeArray();
  149.  
  150.   setCommands();
  151.   // ** compare active and current set
  152.   CURRENT_SHORTCUT_LIST.shortcutListName = ACTIVE_SET_STR;
  153.   setShortcutList();
  154.     MENU_CURRENT_SET.focus();
  155.  
  156. }
  157.  
  158. function adjustButtons()
  159. {
  160.   if (PLATFORM=="Win32")
  161.   {
  162.     document.leftBtn.innerHTML = '<input type="button" name="okBtn" value=' + MM.BTN_OK + ' style="width:75px;height:21px" onClick="cmdOK()">';
  163.     document.middleBtn.innerHTML = '<input type="button" name="cancelBtn" value=' + MM.BTN_Cancel + ' style="width:75px;height:21px" onClick="cmdCancel()">';
  164.     document.rightBtn.innerHTML = '<input type="button" name="helpBtn" value=' + MM.BTN_Help + ' style="width:75px;height:21px" onClick="displayHelp()">';
  165.   }
  166. }
  167.  
  168. // getCustomSetList
  169. // gets the list of custom sets. in DW4, this function returned a single array of
  170. // filenames. it now returns an array containing two items: an array of set names,
  171. // and an array of set filenames. this is so the set names can be localized independent
  172. // of the filenames.
  173. function getCustomSetList(setType)
  174. {
  175.   var fileObj = new File(FILE_CUSTOM_SET);
  176.   var fileArray = new Array();
  177.   var setNames = new Array();
  178.   var filterFunction;
  179.   var setDOM, setName;
  180.   if (setType == "factory")
  181.     filterFunction =  new Function("x", "return (x.isFile()) && ((x.getAttributes() == 'R') || (x.getContents().indexOf('factory') != -1)) && (x.getExtension()== 'xml');");
  182.   else
  183.     filterFunction =  new Function("x", "return (x.isFile()) && ((x.getAttributes() != 'R') && (x.getContents().indexOf('factory') == -1)) && (x.getExtension()== 'xml');");
  184.   fileArray = fileObj.listFolder(filterFunction);
  185.   
  186.   for (var i=0; i < fileArray.length; i++){
  187.     setDOM = dw.getDocumentDOM(FILE_CUSTOM_SET + "/" + fileArray[i]);
  188.     setName = setDOM.getElementsByTagName('SHORTCUTSET')[0].getAttribute('name');
  189.     setNames.push(setName);
  190.   }
  191.   return new Array(setNames,fileArray);
  192. }
  193.  
  194. // function reads in menus.xml and creates the treecontrol
  195. function readFromMenuXML(tagName,id)
  196. {
  197.   loadGlobals();
  198.  
  199.   var menuFile, theMenubar, i, menubarList;
  200.   var tempArray = new Array();
  201.  
  202.   menuFile = new File(FILE_MENUXML_PATH);
  203.   if (!menuFile.exists)
  204.   {
  205.     menuFile.setPath(FILE_CONFIG_PATH + '/Menus/menus.bak');
  206.     menuFile.copyTo(FILE_MENUXML_PATH);
  207.   }
  208.   menuFile.setPath(FILE_MENUXML_PATH);
  209.   menubarList = MENU_DOM.getElementsByTagName(tagName);
  210.   theMenubar = getMenuTagByID(menubarList,id);
  211.  
  212.   // Call into the C++ layer to read the menus.xml file into our desired html 
  213.    // This call traverses the menus in the menubar node and creates treenodes
  214.    // Returns an object with nodes, and parallel arrays of nodenames and keys
  215.   var treeData = dw.getMenuTree(FILE_MENUXML_PATH, tagName, id);
  216.  
  217.   // It's possible in theory, although highly unlikely, to get NULL back from getMenuTree(),
  218.   // so fail gracefully and return an empty list, and bypass adding stuff to the shortcut list
  219.   if(treeData == null)
  220.     return (new Array());
  221.  
  222.   var nodes = treeData.nodes;
  223.  
  224.   // Use the nodename and keys stuff from the C++ call to populate our shortcutlists too
  225.   addShortcutsFromTree(treeData);
  226.  
  227.   return nodes;
  228. }
  229.  
  230.  
  231.  
  232. // function returns the NodeList for the specified tag (it assumes that menus.xml exists).
  233. // Returns null if the tag does not exists.
  234. function getMenuTagByID(menubarList,id)
  235. {
  236.   var   i;
  237.   var found = false;
  238.   for(i=0;i<menubarList.length; i++)
  239.   {
  240.     if  ((menubarList[i].nodeType==Node.ELEMENT_NODE) && (menubarList[i].getAttribute("id") == id))
  241.     {
  242.       found = true;
  243.       break;
  244.     }
  245.   }
  246.   return (found)?menubarList[i]:null;
  247. }
  248.  
  249. // changes the treecontrol when user has selected a different Commands set
  250. function setCommands()
  251. {
  252.   findObject("theTreeControl").innerHTML = ARRAY_COMMANDS_TREE[MENU_COMMANDS.getIndex()];
  253. }
  254.  
  255. // changes the itemList to show the shortcuts for the select tree node
  256. function setShortcutList()
  257. {
  258.   var keyStr="", index, theValue, theSelectedNode;
  259.   theSelectedNode = findObject("theTreeControl").selectedNodes[0];
  260.   if (theSelectedNode)
  261.   {
  262.     theValue = theSelectedNode.value;
  263.     index = theValue.lastIndexOf("|");
  264.     if (index != -1)
  265.       keyStr = theValue.substring(index+1);
  266.   }
  267.   if (keyStr)
  268.     LIST_SHORTCUTS.setAll(keyStr.split(","));
  269.   else
  270.     LIST_SHORTCUTS.setAll(new Array());
  271.   LIST_SHORTCUTS.setIndex(0);
  272. }
  273.  
  274. // updates the key column of the selected treenode
  275. function setShortcutInTree(selectedNode,oldKey,newKey, conflictID)
  276. {
  277.   var  index, treeNodeValue,numUpdates,keyStr;
  278. //  keyStr = LIST_SHORTCUTS.list.toString();
  279.   if (selectedNode)
  280.   {
  281.     numUpdates=CURRENT_SHORTCUT_LIST.update(selectedNode.name, convertKeyStr(newKey,"store"),convertKeyStr(oldKey,"store"));
  282.     keyStr = convertKeyStr(CURRENT_SHORTCUT_LIST.getKeyByID(selectedNode.name),"display")
  283.     treeNodeValue = selectedNode.value;
  284.     if (treeNodeValue.search(/\|/)!=-1){
  285.       treeNodeValue = treeNodeValue.replace(/\|.*/,"|"+keyStr);
  286.     }else
  287.       treeNodeValue += "|"+keyStr;
  288.     selectedNode.setAttribute("value",treeNodeValue);
  289.   }
  290.   else
  291.   {
  292.     numUpdates=1+CURRENT_SHORTCUT_LIST.update(conflictID, convertKeyStr(newKey,"store"),convertKeyStr(oldKey,"store"));
  293.   }
  294.  
  295.   if (numUpdates > 1)
  296.   {
  297.     ARRAY_COMMANDS_TREENODES = updateTreeNodeArray(ARRAY_COMMANDS_TREENODES);
  298.   generateTreeArray();
  299. //  setCommands();
  300.   dw.forceGarbageCollection();
  301.   }
  302.   else
  303.     ARRAY_COMMANDS_TREE[MENU_COMMANDS.getIndex()] = findObject("theTreeControl").innerHTML;
  304. //  document.newShortcutEntry.setAttribute("value", "");
  305.   // *** it would be nice to set A_C_T before user changes commands set instead
  306.  
  307. }
  308.  
  309. function writeToMenusXML(theShortcutList)
  310. {
  311.   loadGlobals();
  312.  
  313.   var i, keyStr, keyArray=new Array(), theId, menuBarNode, menuNode, altId, tempNode;
  314.   var menuitemList, shortcutItemList, shortcutTagList, menuFile;
  315.  
  316.   menuitemList = MENU_DOM.getElementsByTagName("menuItem");
  317.   shortcutItemList = MENU_DOM.getElementsByTagName("shortcut");
  318.   shortcutTagList = MENU_DOM.getElementsByTagName("shortcutlist");
  319.  
  320.   for (i=0;i<theShortcutList.idKeyPairList.length; i++ )
  321.   {
  322.     keyArray = theShortcutList.idKeyPairList[i].keysArray;
  323.  
  324.     theId = theShortcutList.idKeyPairList[i].id;
  325.     if (theId && theShortcutList.changeList[theId])
  326.     {
  327.       //set the primary key
  328.       if (theId.indexOf("DWShortcut") == -1){
  329.         menuNode = getMenuTagByID(menuitemList, theId);
  330.         if (!menuNode) menuNode = getMenuTagByID(shortcutItemList, theId);
  331.       }
  332.       else{
  333.         menuNode = getMenuTagByID(shortcutItemList, theId);
  334.         if (!menuNode) menuNode = getMenuTagByID(menuitemList, theId);
  335.       }
  336.       if (menuNode != null && menuNode.getAttribute("key")!= keyArray[0]){
  337.       if (keyArray[0])
  338.         menuNode.setAttribute("key", keyArray[0]);
  339.       else
  340.         menuNode.setAttribute("key", "");
  341.       }
  342.     //set Alternate key
  343.  
  344.       shortcutTagID = getTagIdFromItemId(theId,menuNode);
  345.       if (shortcutTagID == "DWMainWindow1")
  346.       {
  347.         rightId = theId.replace(/DWMenu_/,"");
  348.         altId = "DWShortcuts_" + rightId;
  349.         shortcutTagID = shortcutTagID.substr(0,shortcutTagID.length-1);
  350.       }
  351.       else if (shortcutTagID == "DWMainSite1")
  352.       {
  353.         rightId = theId.replace(/DWMenu_MainSite/,"");
  354.         altId = "DWShortcuts_MainSite" + rightId;
  355.         shortcutTagID = shortcutTagID.substr(0,shortcutTagID.length-1);
  356.       }
  357.       else
  358.       {
  359.         altId = theId+"2";
  360.       }
  361.       if (keyArray.length > 1 && menuNode)
  362.       {
  363.         if (getMenuTagByID(shortcutItemList, altId) == null)   // check to see if alt already exists
  364.         {
  365.           tempNode = getMenuTagByID(shortcutTagList, shortcutTagID)
  366.           if (tempNode)
  367.             tempNode.innerHTML += createAltShortcutTag(menuNode, altId, keyArray[1]);
  368.         }
  369.         else
  370.         {
  371.           menuNode = getMenuTagByID(shortcutItemList, altId);
  372.           if (menuNode)
  373.             menuNode.setAttribute("key", keyArray[1]);
  374.           if (menuNode.getAttribute("platform")==OPP_PLATFORM)
  375.           menuNode.setAttribute("platform", "");
  376.         }
  377.       }
  378.       else if ((menuNode = getMenuTagByID(shortcutItemList, altId)) != null)
  379.       {
  380.         if (menuNode.getAttribute("platform")!=OPP_PLATFORM)
  381.           menuNode.setAttribute("key", "");
  382.       }
  383.     }
  384.   }
  385.   menuFile = new File(FILE_MENUXML_PATH);
  386.  
  387.   if (dreamweaver.appVersion && (dreamweaver.appVersion.indexOf('ja') != -1 || 
  388.                                  dreamweaver.appVersion.indexOf('ko') != -1 ||
  389.                                  dreamweaver.appVersion.indexOf('zh') != -1) )
  390.     menuFile.setContents(MENU_DOM.body.outerHTML);
  391.   else
  392.     menuFile.setContents(dreamweaver.nativeToLatin1(MENU_DOM.body.outerHTML));
  393. }
  394.  
  395. function createAltShortcutTag(origNode, newId, newKey)
  396. {
  397.  
  398.   var retVal = new Array(), value;
  399.   var attrArray  = new Array("file","command","domRequired","arguments","enabled","name")
  400.   retVal.push(NEWLINE + "    <shortcut key=" + '"' + newKey + '"');
  401.   for (var i=0; i<attrArray.length; i++)
  402.   {
  403.     if ((value = origNode.getAttribute(attrArray[i])))
  404.       retVal.push("   "+attrArray[i]+"=" + '"' + value + '"');
  405.   }
  406.   retVal.push("   id=" + '"' + newId + '" />'+NEWLINE);
  407.   return retVal.join("");
  408. }
  409.  
  410. // Given an items it, returns the id of the menubar id
  411. function getTagIdFromItemId(itemId,menuNode)
  412. {
  413.   var retVal="",parent, parentId;
  414.   parent = menuNode.parentNode;
  415.   if (menuNode)
  416.   {
  417.     if (parent.tagName =="SHORTCUTLIST")
  418.       retVal = parent.getAttribute("id");
  419.     else
  420.     {
  421.       while (parent && !parentId)
  422.       {
  423.         if (parent.tagName =="MENUBAR")
  424.           parentId = parent.getAttribute("id");
  425.         else
  426.           parent = parent.parentNode;
  427.       }
  428.     }
  429.     if (parentId)
  430.     {
  431.       if (parentId =="DWMainSite")
  432.         retVal = "DWMainSite1"
  433.       else if (parentId =="DWMainWindow")
  434.         retVal = "DWMainWindow1"
  435.     }
  436.   }
  437.   return retVal;
  438. }
  439.  
  440. function getAltKeyId(id)
  441. {
  442.  var retVal="";
  443.  if (!id )
  444.    return retVal;
  445.  else if (id.indexOf("DWMenu_")!=-1)
  446.    retVal = id.replace(/DWMenu_/,"DWShortcuts_");
  447.  else if (id)
  448.    retVal = id+"2";
  449.  return retVal;
  450. }
  451.  
  452. function isShortcutToExclude(id)
  453. {
  454.   var retVal=true,i, tempId;
  455.   var idPrefixArray = new Array("DWShortcuts_Main_","DWShortcuts_Site_","DWShortcuts_HTMLSource_");
  456.   if (id && id.indexOf("DWShortcuts")!=-1)
  457.   {
  458.   var tempId = (id.charAt(id.length-1)=="2") ? id.substring(0,id.length-1): "";
  459.   if (tempId && CURRENT_SHORTCUT_LIST.getIndexByID(tempId) != -1)
  460.     retVal = true;
  461.   else
  462.   {
  463.       for (i=0;i<idPrefixArray.length;i++)
  464.       {
  465.         if (id && id.indexOf(idPrefixArray[i]) != -1)
  466.         {
  467.           retVal = false;
  468.           break;
  469.         }
  470.       }
  471.     }
  472.   }
  473.   else retVal=false;
  474.   return retVal;
  475. }
  476.  
  477. function getIndexOfItem(theArray,theItem)
  478. {
  479.   var index,found=false;
  480.   for (index=0;index<theArray.length;index++)
  481.   {
  482.     if (theArray[index] == theItem)
  483.     {
  484.       found=true;
  485.       break;
  486.     }
  487.   }
  488.   return (found)? index:-1;
  489. }
  490.  
  491. function updateUI(itemName)
  492. {
  493.   var newSetFile, newSetName, retVal, tempStr,errorMsg,selectedTreeNode,keyStr,oldKey,numUpdate,otherNode;
  494.   var tempShortcutList;
  495.   switch(itemName)
  496.   {
  497.     case "selectCurrentSet":
  498.   {
  499.     if (MENU_CURRENT_SET.get() == SEPARATOR_STR)
  500.     {
  501.         MENU_CURRENT_SET.pickValue(LAST_VALID_COMMAND_MI);
  502.         //document.commandsList.focus()
  503.     }
  504.     else
  505.     {
  506.       if  (!isSet(MENU_CURRENT_SET.getValue(), "factory")
  507.            && (CURRENT_SHORTCUT_LIST.changeListLength() > 0 )&& confirm(MSG_SaveShortcutSet))
  508.       CURRENT_SHORTCUT_LIST.writeToShortcutXML(FILE_CUSTOM_SET+"/" + MENU_CURRENT_SET.getValue(), CURRENT_SHORTCUT_LIST.shortcutListName);
  509.       MM.setBusyCursor();
  510.       newSetFile = MENU_CURRENT_SET.getValue();
  511.       if (getExtension(newSetFile) !="xml")
  512.         newSetFile+=".xml"
  513.       tempShortcutList = new ShortcutList();
  514.       tempShortcutList.readFromShortcutXML(FILE_CUSTOM_SET+"/" + newSetFile);
  515.       CURRENT_SHORTCUT_LIST.compareUpdate(tempShortcutList);
  516.       ARRAY_COMMANDS_TREENODES = updateTreeNodeArray(ARRAY_COMMANDS_TREENODES);
  517.       generateTreeArray();
  518.       setCommands();
  519.       dw.forceGarbageCollection();
  520.       MM.clearBusyCursor();
  521.     }
  522.     LIST_SHORTCUTS.setAll("");
  523.     clearField("newShortcutEntry");
  524.     LAST_VALID_COMMAND_MI = MENU_CURRENT_SET.getValue();
  525.     MENU_CURRENT_SET.focus()
  526.     break;
  527.   }
  528.   case "duplicateBtn":
  529.     {
  530.     newSetName = callCommand("duplicate set",new Array(MENU_CURRENT_SET.getValue(),CURRENT_SHORTCUT_LIST));
  531.     if (newSetName)
  532.     {
  533.       CURRENT_SHORTCUT_LIST.shortcutListName = newSetName;
  534.       DWfile.write(FILE_ACTIVE_SET,newSetName);
  535.       setCurrentSetMenu();
  536.       MENU_CURRENT_SET.setIndex(getIndexOfItem(MENU_CURRENT_SET.get('all'),newSetName));
  537.       updateUI("selectCurrentSet");
  538.     }
  539.     break;
  540.     }
  541.   case "renameBtn":
  542.   {
  543.     if (!isSet(MENU_CURRENT_SET.getValue(), "factory"))
  544.     {
  545.       newSetName = callCommand("rename set",MENU_CURRENT_SET.getValue());
  546.       if (newSetName)
  547.       {
  548.         CURRENT_SHORTCUT_LIST.shortcutListName = newSetName;
  549.         DWfile.write(FILE_ACTIVE_SET,newSetName);
  550.         setCurrentSetMenu();
  551.         MENU_CURRENT_SET.setIndex(getIndexOfItem(MENU_CURRENT_SET.get('all'),newSetName));
  552.       }
  553.     }
  554.     else
  555.       alert(MSG_CannotRenameFactorySet);
  556.     break;
  557.   }
  558.   case "deleteBtn":
  559.   {
  560.     tempStr = CURRENT_SHORTCUT_LIST.shortcutListName;
  561.     tempStr = tempStr.replace(/.xml/,"");
  562.     retVal = callCommand("delete set",tempStr);
  563.     if (retVal)
  564.     {
  565.       setCurrentSetMenu();
  566.       MENU_CURRENT_SET.setIndex(getIndexOfItem(MENU_CURRENT_SET.get('all'),ACTIVE_SET_STR));
  567.     }
  568.     break;
  569.   }
  570.   case "commandsList":
  571.   { // update the treecontrol
  572.     if (MENU_COMMANDS.get() ==SEPARATOR_STR)
  573.     {
  574.       MENU_COMMANDS.setIndex(MENU_COMMANDS.getIndex()-1);
  575.       updateUI("commandsList");
  576.     }
  577.     else
  578.       setCommands();
  579.     document.newShortcutEntry.setAttribute("value", "")
  580.     updateUI("newShortcutEntry");
  581.     LIST_SHORTCUTS.setAll("");
  582.     break;
  583.   }
  584.   case "theTreeControl":
  585.   {
  586.     ARRAY_COMMANDS_TREE[MENU_COMMANDS.getIndex()] = findObject("theTreeControl").innerHTML;
  587.     setShortcutList();
  588.     clearField("newShortcutEntry");
  589.     break;
  590.   }
  591.   case "addBtn":
  592.   { // node.childNodes.length
  593.     if (!isSet(MENU_CURRENT_SET.getValue(), "factory"))
  594.     {
  595.         selectedTreeNode = findObject("theTreeControl").selectedNodes[0];
  596.       if (selectedTreeNode && selectedTreeNode.childNodes.length == 0 )
  597.       {
  598.         if ((LIST_SHORTCUTS.getLen()==0 || LIST_SHORTCUTS.get() !="" ) && LIST_SHORTCUTS.getLen() < 2)
  599.         {
  600.           LIST_SHORTCUTS.append();
  601.           document.newShortcutEntry.focus();
  602.           document.newShortcutEntry.select();
  603.         }
  604.     }
  605.       }
  606.     else
  607.     {
  608.       if (confirm (MSG_FactorySetCannotBeModified))
  609.         updateUI("duplicateBtn");
  610.     }
  611.     break;
  612.   }
  613.   case "minusBtn":
  614.   {
  615.       if (findObject("theTreeControl").selectedNodes[0])
  616.     {
  617.       if (!isSet(MENU_CURRENT_SET.getValue(), "factory"))
  618.       {
  619.         if (LIST_SHORTCUTS.getLen!=0)
  620.         {
  621.           selectedTreeNode = findObject("theTreeControl").selectedNodes[0];
  622.             oldKey = LIST_SHORTCUTS.get();
  623.       if (oldKey)
  624.             setShortcutInTree(selectedTreeNode,oldKey,"");
  625.       LIST_SHORTCUTS.del();
  626.         }
  627.       }
  628.       else
  629.       {
  630.         if (confirm (MSG_FactorySetCannotBeModified))
  631.           updateUI("duplicateBtn");
  632.       }
  633.     }
  634.     break;
  635.   }
  636.   case "newShortcutEntry":
  637.   {
  638.     if (!document.newShortcutEntry.value || !isSet(MENU_CURRENT_SET.getValue(), "factory"))
  639.     {
  640.       errorMsg = checkKeyForConflict(convertKeyStr(document.newShortcutEntry.value,"store"));
  641.       if(errorMsg)
  642.       {
  643.         findObject("warningMessage").innerHTML = errorMsg;
  644.       }
  645.       else if(findObject("warningMessage").innerHTML != "")
  646.       {
  647.           findObject("warningMessage").innerHTML = "";
  648.       }
  649.       }
  650.       else
  651.       {
  652.       if (confirm (MSG_FactorySetCannotBeModified))
  653.         updateUI("duplicateBtn");
  654.     }
  655. //    if (document.newShortcutEntry.value=="")
  656. //    {
  657. //        document.applyButton.setAttribute("disabled","true");
  658. //    }
  659.     break;
  660.   }
  661.   case "applyButton":
  662.   {
  663.     if (CAN_APPLY)
  664.     {
  665.       if (!isSet(MENU_CURRENT_SET.getValue(), "factory"))
  666.       {
  667.         selectedTreeNode = findObject("theTreeControl").selectedNodes[0];
  668.         if (!selectedTreeNode || selectedTreeNode.childNodes.length != 0 )
  669.           break;
  670.         if (CONFLICT_ID && !confirm(errMsg(MSG_ReassignShortcut,getNameFromTreeArray(CONFLICT_ID),getNameFromTreeArray(document.theTreeControl.selectedNodes[0].name))))
  671.           break;
  672.         else
  673.         {
  674.           if (CONFLICT_ID)
  675.           {
  676. //            CURRENT_SHORTCUT_LIST.update(CONFLICT_ID,"",convertKeyStr(document.newShortcutEntry.value,"store"));
  677.             otherNode = document.theTreeControl[CONFLICT_ID];
  678.             if (otherNode)
  679.               setShortcutInTree(otherNode,document.newShortcutEntry.value,"")
  680.             else
  681.               setShortcutInTree(null,document.newShortcutEntry.value,"",CONFLICT_ID);
  682.           }
  683.           if (LIST_SHORTCUTS.getLen() == 0)
  684.             LIST_SHORTCUTS.add("");
  685.           oldKey = LIST_SHORTCUTS.get();
  686.           LIST_SHORTCUTS.set(document.newShortcutEntry.value);
  687.           setShortcutInTree(selectedTreeNode,oldKey,document.newShortcutEntry.value);
  688.         }
  689.       }
  690.       else
  691.       {
  692.         if (confirm (MSG_FactorySetCannotBeModified))
  693.           updateUI("duplicateBtn");
  694.       }
  695.       document.newShortcutEntry.setAttribute("value", "")
  696.       updateUI("newShortcutEntry");
  697.     }
  698.     dw.forceGarbageCollection();
  699.     break;
  700.   }
  701.   }
  702. }
  703.  
  704. function generateTreeControlHtml(treeNodesArray)
  705. {
  706.   var retVal = new Array();
  707.   var treeControlTag = 'MM:TREECONTROL';
  708.   var treeColumnTag = 'MM:TREECOLUMN';
  709.   var treeColWidth = (PLATFORM=="Win32") ? TREE_COLUMN_ITEM_WIDTH : TREE_COLUMN_ITEM_WIDTH_MAC;
  710.   retVal.push( "  <" + treeColumnTag + ' name="menuitems" ' + TREE_COLUMN_ITEM_WIDTH + '>' + NEWLINE);
  711.   retVal.push("  <" + treeColumnTag + ' name="shortcutKeys" ' + TREE_COLUMN_KEY_WIDTH + '>' + NEWLINE);
  712.   retVal.push(treeNodesArray.join(""));
  713.   return retVal.join("");
  714. }
  715.  
  716. function generateTreeArray()
  717. {
  718.   var i=0;
  719.   if (ARRAY_COMMANDS_TREE.length==0)
  720.     ARRAY_COMMANDS_TREE.length = ARRAY_COMMANDS_TREENODES.length;
  721.   for (i=0;i<ARRAY_COMMANDS_TREENODES.length;i++)
  722.   {
  723.     if (ARRAY_COMMANDS_TREENODES[i] !="-")
  724.       ARRAY_COMMANDS_TREE[i]=generateTreeControlHtml(ARRAY_COMMANDS_TREENODES[i]);
  725.     else
  726.       ARRAY_COMMANDS_TREE[i] = "-";
  727.   }
  728. }
  729.  
  730. function updateTreeNodeArray(arrayOfTreeNodeArrays)
  731. {
  732.   var i, x, theNodeStr;
  733.   for (i=0; i < arrayOfTreeNodeArrays.length; i++)
  734.   {
  735.     for (x=0; x <  arrayOfTreeNodeArrays[i].length; x++)
  736.     {
  737.       theNodeStr = updateTreeNode(arrayOfTreeNodeArrays[i][x]);
  738.       if (theNodeStr != arrayOfTreeNodeArrays[i][x]);
  739.         arrayOfTreeNodeArrays[i][x] = theNodeStr;
  740.     }
  741.   }
  742.   return arrayOfTreeNodeArrays;
  743. }
  744.  
  745. function updateTreeNode(treeNodeStr)
  746. {
  747.   var startIndex=0, keyStr, newStr, endIndex=0;
  748.   if (treeNodeStr.indexOf('name="DW') !=-1)
  749.   {
  750.     startIndex = treeNodeStr.indexOf('name="DW',startIndex)+6;
  751.     endIndex = treeNodeStr.indexOf('"',startIndex);
  752.     theId = treeNodeStr.substr(startIndex, endIndex-startIndex);
  753.  
  754.     // get keyStr for the given id
  755.     keyStr = convertKeyStr(CURRENT_SHORTCUT_LIST.getKeyByID(theId),"display");
  756.   if(treeNodeStr.indexOf("|"+keyStr+'"') == -1 ||!keyStr && treeNodeStr.indexOf("|")!=-1)
  757.     {
  758.       startIndex=treeNodeStr.indexOf("|");
  759.       if (startIndex==-1)
  760.       {
  761.         startIndex = treeNodeStr.indexOf('value="')+7;
  762.         startIndex = treeNodeStr.indexOf('"',startIndex);
  763.       }
  764.       endIndex = treeNodeStr.indexOf('"', startIndex);
  765.       newStr = treeNodeStr.substr(0, startIndex);
  766.       if (keyStr) newStr += "|";
  767.         newStr += keyStr + treeNodeStr.substr(endIndex);
  768.       treeNodeStr = newStr;
  769.     }
  770.   }
  771.   return treeNodeStr;
  772. }
  773.  
  774. function setCurrentSetMenu()
  775. {
  776.   var factorySets = getCustomSetList("factory");
  777.   var customSets = getCustomSetList("custom");
  778.   if (customSets[0].length !=0){
  779.     factorySets[0].push(SEPARATOR_STR);
  780.     factorySets[1].push(SEPARATOR_STR);
  781.   }
  782.   var currentSetNames = factorySets[0].concat(customSets[0]);
  783.   var currentSetFiles = factorySets[1].concat(customSets[1]);
  784.  
  785.   ACTIVE_SET_STR = DWfile.read(FILE_ACTIVE_SET);
  786.   MENU_CURRENT_SET.setAll(currentSetNames,currentSetFiles);
  787. }
  788.  
  789. function isKeyWithoutCtrl(theKey)
  790. {
  791.   var retVal=false;
  792.   if (theKey.length == 1)
  793.     retVal = true;
  794.   else
  795.   {
  796.     index = theKey.lastIndexOf("+");
  797.     tempStr = theKey.substring(index+1);
  798.     if (PLATFORM=="Win32")
  799.     {
  800.       if (tempStr.length == 1 && theKey.indexOf("Cmd") == -1 && theKey.indexOf("Ctrl") == -1)
  801.         retVal = true;
  802.     }
  803.     else 
  804.     {
  805.       if (tempStr.length == 1 && theKey.indexOf("Cmd") == -1)
  806.         retVal = true;
  807.     }
  808.   }
  809.   return retVal;
  810. }
  811.  
  812. // returns error message if the given shortcut key is invalid
  813. function checkKeyForConflict(newKey)
  814. {
  815.   var retVal, conflictId;
  816.   if (newKey)
  817.     conflictId = CURRENT_SHORTCUT_LIST.getIdByKey(newKey);
  818.   if (PLATFORM == "Win32" && conflictId == "" && newKey.indexOf("Cmd") != -1)
  819.   {
  820.       newKey = newKey.replace(/Cmd/,"Ctrl");
  821.       conflictId = CURRENT_SHORTCUT_LIST.getIdByKey(newKey);
  822.   }
  823.       
  824.   CONFLICT_ID = conflictId;
  825.   if (isKeyWithoutCtrl(newKey))
  826.   {
  827.     retVal = createWarningMsg();
  828.     CAN_APPLY = false;
  829. //    document.applyButton.setAttribute("disabled","true");
  830.   }
  831.   else
  832.   {
  833. //    document.applyButton.setAttribute("disabled","false");
  834.     CAN_APPLY = true;
  835.     if (conflictId)
  836.       retVal = createWarningMsg(getNameFromTreeArray(conflictId));
  837.     else
  838.       retVal="";
  839.   }
  840.   return retVal;
  841. }
  842.  
  843. function createWarningMsg(theId)
  844. {
  845.   var retVal = new Array();
  846.   if (theId)
  847.   {
  848.     imagePath = YIELD_PATH;
  849.     messageStr = MSG_ShortcutAssigned;
  850.     errorMsgArg = theId;
  851.   }
  852.   else
  853.   {
  854.     imagePath = STOP_PATH;
  855.     messageStr = MSG_LetterShortcutMustHaveCtrl;
  856.     errorMsgArg = CTRL_STR;
  857.   }
  858.   retVal.push('<img src="'+ imagePath + '" width="12" height="12" >');
  859.   retVal.push(errMsg(messageStr, errorMsgArg));
  860.   return retVal.join("");
  861. }
  862.  
  863.  
  864. function isSet(setFileName, setType)
  865. {
  866.   var facSetArray = new Array(), i, retVal = false;
  867.   facSetArray = getCustomSetList(setType)[1];
  868.   if (setFileName.lastIndexOf(".xml") != setFileName.length-4)
  869.     setFileName = setFileName + ".xml";
  870.   for (i=0; i<facSetArray.length; i++)
  871.   {
  872.     if (facSetArray[i] == setFileName)
  873.     {
  874.       retVal = true;
  875.       break;
  876.     }
  877.   }
  878.   return retVal;
  879. }
  880.  
  881. function createHTMLContents()
  882. {
  883.   var retVal = new Array(), i, treeNodeStr, keyStr,currLevel;
  884.   var nextNodeStr="",isBold,tempNodeStr;
  885.   var closeTreeNodeStr='</MM:TREENODE>'+ NEWLINE;
  886.   retVal.push("<HTML>"+NEWLINE+"<HEAD>");
  887.   retVal.push("<TITLE>" + CURRENT_SHORTCUT_LIST.shortcutListName + " Shortcut Set" + "</TITLE>" +NEWLINE);
  888.   retVal.push('<style type="text/css">\n<!--\nbody {font-family:  '  + cssfontStr + '; text-align: center}\ntable {  font-size: x-small}\n-->\n</style>')
  889.   retVal.push("</HEAD>"+NEWLINE);
  890.   retVal.push('<BODY BGCOLOR="#FFFFFF">');
  891.   retVal.push('<DIV ALIGN="center">');
  892.   retVal.push('<p><b><font size="6">'+ MENU_CURRENT_SET.get()+'</font></b></p>\n<p><b>' + DW_VERSION + '</b></p>')
  893.   ARRAY_COMMANDS_TREENODES = updateTreeNodeArray(ARRAY_COMMANDS_TREENODES);
  894.   for (i=0;i<ARRAY_COMMANDS_TREENODES.length;i++)
  895.   {
  896.     if (ARRAY_COMMANDS_TREENODES[i]!="-")
  897.     {
  898.       retVal.push("<p><b>"+MENU_COMMANDS.get(i)+"</b></p>"+NEWLINE);
  899.       retVal.push('<TABLE border = "1" cellspacing="0" cellpadding="2">'+NEWLINE);
  900.       for(x=0;x<ARRAY_COMMANDS_TREENODES[i].length;x++)
  901.       {
  902.         treeNodeStr = ARRAY_COMMANDS_TREENODES[i][x];
  903.         for (var k=x+1;k<ARRAY_COMMANDS_TREENODES[i].length;k++)
  904.         {
  905.         tempNodeStr = ARRAY_COMMANDS_TREENODES[i][k];
  906.         if (tempNodeStr != closeTreeNodeStr){
  907.         nextNodeStr = tempNodeStr;
  908.           break;
  909.       }
  910.       }
  911.         currLevel = getTreeNodeLevel(treeNodeStr);
  912.         isBold = (nextNodeStr && (getTreeNodeLevel(nextNodeStr) > currLevel))
  913.         if (treeNodeStr != closeTreeNodeStr)
  914.       {
  915.           retVal.push("<TR>"+NEWLINE);
  916.         retVal.push("<TD>");
  917.         for(var j=0; j<currLevel*4; j++)
  918.           retVal.push(" ")
  919.         if (isBold)
  920.           retVal.push("<b>");
  921.         retVal.push(getTreeNodeValue(treeNodeStr,1))
  922.         if (isBold)
  923.           retVal.push("</b>");
  924.         retVal.push("</TD>"+NEWLINE);
  925.         keyStr = getTreeNodeValue(treeNodeStr,2);
  926.         if (!keyStr) keyStr = " ";
  927.         retVal.push("<TD>"+keyStr+"</TD>"+NEWLINE);
  928.         retVal.push("</TR>"+NEWLINE);
  929.       }
  930.       }
  931.       retVal.push("</TABLE>");
  932.     }
  933.   }
  934.   retVal.push("</div>"+NEWLINE + "</BODY>"+NEWLINE+"</HTML>");
  935.   return retVal.join("");
  936. }
  937.  
  938. function getTreeNodeValue(treeNodeStr,column)
  939. {
  940.   var startIndex, endIndex, valueStr, valueArray, retVal ="";
  941.   startIndex = treeNodeStr.indexOf('value="')+7;
  942.   endIndex = treeNodeStr.indexOf('"', startIndex);
  943.   valueStr = treeNodeStr.substring(startIndex,endIndex);
  944.   valueArray = valueStr.split("|");
  945.   if (valueArray.length >= column)
  946.   retVal = valueArray[column-1];
  947.   return retVal;
  948. }
  949.  
  950. function getTreeNodeLevel(treeNodeStr)
  951. {
  952.   var startIndex, endIndex, valueStr="0", valueArray;
  953.   startIndex = treeNodeStr.indexOf('level="')+7;
  954.   endIndex = treeNodeStr.indexOf('"', startIndex);
  955.   valueStr = treeNodeStr.substring(startIndex,endIndex);
  956.   return (valueStr) ? valueStr : 0;
  957. }
  958.  
  959. function getSimpleName(filenameArray)
  960. {
  961.   var i;
  962.   for (i=0;i<filenameArray.length;i++)
  963.   {
  964.     if (filenameArray[i].lastIndexOf(".xml") == filenameArray[i].length-4)
  965.       filenameArray[i] = filenameArray[i].replace(/.xml/,"");
  966.   }
  967.   return filenameArray;
  968. }
  969.  
  970. function getExtension(fileName)
  971. {
  972.   var retVal = "", index;
  973.  
  974.   index = fileName.lastIndexOf(".");
  975.   if (index != -1)
  976.     retVal = fileName.substring(index+1);
  977.   return retVal;
  978. }
  979.  
  980. function getSimpleFileName(fileName)
  981. {
  982.   var index; retVal = fileName;
  983.  
  984.   index = fileName.lastIndexOf(".");
  985.   if (index != -1)
  986.     retVal = fileName.substring(0,index);
  987.   return retVal;
  988. }
  989.  
  990. function convertKeyStr(keyStr,location)
  991. {
  992.   var retVal=keyStr;
  993.   if (PLATFORM=="Win32")
  994.   {
  995.     if (location === "display")
  996.     {
  997.       if (retVal.indexOf("Cmd")!=-1)
  998.         retVal = retVal.replace(/Cmd/g,"Ctrl");
  999.       if (retVal.indexOf("Opt")!=-1)
  1000.         retVal = retVal.replace(/Opt/g,"Alt");
  1001.     }
  1002.     if (location  == "store")
  1003.     {
  1004.       if (retVal.indexOf("Ctrl")!=-1)
  1005.         retVal = retVal.replace(/Ctrl/g,"Cmd");
  1006.       if (retVal.indexOf("Alt")!=-1)
  1007.         retVal = retVal.replace(/Alt/g,"Opt");
  1008.     }
  1009.   }
  1010.   return retVal;
  1011. }
  1012.  
  1013. function getPressedKeys()
  1014. {
  1015.   var eventObj = window.event;
  1016.   var retVal = new Array();
  1017.   var theKeyCode = eventObj.keyCode;
  1018.   var charCode = dw.mapKeyCodeToChar(theKeyCode);
  1019.   var keyStr = KEY_CODES[theKeyCode];
  1020.   var modifierFound = false, nonModifier=false;
  1021.   if (eventObj.ctrlKey)
  1022.     retVal.push("Ctrl");
  1023.   if (eventObj.cmdKey)
  1024.     retVal.push("Cmd");
  1025.   if (eventObj.altKey)
  1026.     retVal.push(ALT_STR);
  1027.   if (eventObj.shiftKey)
  1028.     retVal.push("Shift");
  1029.   if (keyStr)
  1030.   retVal.push(keyStr);
  1031.   else if (charCode !=0)
  1032.     retVal.push(String.fromCharCode(charCode));
  1033.  
  1034.   // allow tab and shift-tab to move cursor in and out off newShortcutEntry
  1035.   if (retVal.length == 1 && keyStr == "Tab"){
  1036.           document.theForm.applyButton.focus();
  1037.           return false;
  1038.   }
  1039.  
  1040.   if (retVal.length == 2 && retVal[0]== 'Shift' && keyStr == "Tab"){
  1041.           document.theForm.itemList.focus();
  1042.           return false;
  1043.   }
  1044.  
  1045.   for (var i=0; i<retVal.length; i++)
  1046.   {
  1047.   modifierFound=false;
  1048.     for (var j=0; j<MODIFIER_KEYS.length; j++)
  1049.     {
  1050.       if (MODIFIER_KEYS[j]== retVal[i])
  1051.       {
  1052.     modifierFound = true;
  1053.       break;
  1054.     }
  1055.   }
  1056.   if (!modifierFound)
  1057.   {
  1058.       nonModifier=true;
  1059.     break;
  1060.     }
  1061.   }
  1062.   if (retVal[0] && nonModifier)
  1063.     document.newShortcutEntry.value = (retVal.length > 1) ? retVal.join("+") : retVal[0];
  1064.   else
  1065.     document.newShortcutEntry.value = "";
  1066.   return false;
  1067. }
  1068.  
  1069. function clearField(objName)
  1070. {
  1071.   document[objName].value = "";
  1072.   updateUI(objName);
  1073. }
  1074.  
  1075. function getNameFromTreeArray(id)
  1076. {
  1077.   var i,x, startIndex, endIndex, pipeIndex, idFound, retVal="";
  1078.  
  1079.   for (i=0; i<ARRAY_COMMANDS_TREENODES.length; i++)
  1080.   {
  1081.     for (x=0; x<ARRAY_COMMANDS_TREENODES[i].length; x++)
  1082.     {
  1083.       nodeStr = ARRAY_COMMANDS_TREENODES[i][x];
  1084.       startIndex = nodeStr.indexOf('name="') + 6;
  1085.       if (startIndex >=6)
  1086.       {
  1087.         endIndex=nodeStr.indexOf('"',startIndex);
  1088.       nodeName=nodeStr.substring(startIndex, endIndex);
  1089.       }
  1090.       if (nodeName == id)
  1091.       {
  1092.         startIndex=nodeStr.indexOf('value="') + 7;
  1093.         if (startIndex >= 7)
  1094.         {
  1095.           pipeIndex = nodeStr.indexOf("|", startIndex);
  1096.           endIndex = (pipeIndex == -1) ? nodeStr.indexOf('"',startIndex) : pipeIndex;
  1097.           retVal = nodeStr.substring(startIndex, endIndex);
  1098.         }
  1099.         idFound=true;
  1100.         break;
  1101.       }
  1102.     }
  1103.     if (idFound)
  1104.       break;
  1105.   }
  1106.   return retVal;
  1107. }
  1108.  
  1109. function checkLockedFiles()
  1110. {
  1111.   loadGlobals();
  1112.  
  1113.   retVal = false;
  1114.   fileArray = new Array(FILE_MENUXML_PATH,FILE_ACTIVE_SET);
  1115.   for (var i=0;i<fileArray.length; i++)
  1116.   {
  1117.     if (DWfile.getAttributes(fileArray[i])=="R")
  1118.     {
  1119.       alert(errMsg(MSG_ReadOnlyFile,fileArray[i]));
  1120.       retVal=true;
  1121.     }
  1122.   }
  1123.   return retVal;
  1124. }
  1125.  
  1126. function addShortcutsFromTree(treeData) {
  1127.     var numElts = treeData.names.length;
  1128.     for(var i=0; i < numElts; i++){
  1129.          CURRENT_SHORTCUT_LIST.addShortcut( treeData.names[i],  treeData.keys[i]);
  1130.     }
  1131.     return;
  1132. }
  1133.  
  1134.